import { CustomerService } from "@src/service";
import { MyError } from "@src/tools";

export const isCustLogin = (req, res, next) => {
    let token = req.headers['token'];
    if(!token) return next(new MyError({code:1001,message:'token id required'}));
    CustomerService.getCustByToken(token).then(cust=>{
        req.user = cust;
        next();
    }).catch(next);
};